New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

imagetools-core

Package Overview
Dependencies
Maintainers
1
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

imagetools-core

<!-- badges -->

  • 3.3.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
72K
decreased by-2.95%
Maintainers
1
Weekly downloads
 
Created
Source

imagetools-core

npm (tag) standard-readme compliant codecov

A toolbox of import directives that can transform your image at compile-time. All of the image transformations are powered by sharp.

This package holds all transforms and core utility functions needed to integrate imagetools with any builtool,
or to create a standalone transformation server!

Read the docs to learn more!

Table of Contents

Install

npm install imagetools-core
yarn add imagetools-core

Usage

import { loadImage, applyTransforms, builtins, generateTransforms } from 'imagetools-core'

// loadImageFromDisk is a utility function that creates a sharp instances of the specified image
const image = loadImage('./example.jpg')

// our image configuration
const config = {
  width: '400',
  height: '300',
  format: 'webp'
}

// This function takes our config and an array of transformFactories and creates an array of transforms
// the resulting array of transforms can be cached
const { transforms, warnings } = generateTransforms(config, builtins)

// apply the transforms and transform the given image
const { image: transformedImage, metadata } = await applyTransforms(transforms, image)

transformedImage // a sharp instance of the transformed image
metadata // the image metadata produced by the transforms
import { parseURL, resolveConfigs } from 'imagetools-core'

const src = new URL('file:///example.jpg?w=300;500;700&format=webp')

// parses the url query parameters into an array of entries
const parameters = parseURL(src)

// this function handles the ArgumentList logic
// and produces an array of config objects that can be passed to generateTransforms
const configs = resolveConfigs(parameters)

Contributing

Feel free to dive in! Open an issue or submit PRs! All information to get you started hacking on imagetools is in CONTRIBUTING.md!

License

MIT © Jonas Kruckenberg.

Keywords

FAQs

Package last updated on 23 Jan 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc